<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Basic usage</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="rpmreader.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.rpmreader.html">RPM Reader 函数</a></div>
 <div class="up"><a href="rpmreader.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="rpmreader.examples-basic" class="section">
  <h2 class="title">Basic usage</h2>
  <p class="para">
   This example will open an RPM file and read the name, version, and
   release from the RPM file, echo the results, and close the RPM file.
  </p>
  <div class="example" id="example-3474">
   <p><strong>Example #1 Basic RPMReader Example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$filename&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"/path/to/file.rpm"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;open&nbsp;file<br /></span><span style="color: #0000BB">$rpmr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rpm_open</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;get&nbsp;"Name"&nbsp;tag<br /></span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rpm_get_tag</span><span style="color: #007700">(</span><span style="color: #0000BB">$rpmr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">RPMREADER_NAME</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;get&nbsp;"Version"&nbsp;tag<br /></span><span style="color: #0000BB">$ver&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rpm_get_tag</span><span style="color: #007700">(</span><span style="color: #0000BB">$rpmr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">RPMREADER_VERSION</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;get&nbsp;"Release"&nbsp;tag<br /></span><span style="color: #0000BB">$rel&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rpm_get_tag</span><span style="color: #007700">(</span><span style="color: #0000BB">$rpmr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">RPMREADER_RELEASE</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$name</span><span style="color: #DD0000">-</span><span style="color: #0000BB">$ver</span><span style="color: #DD0000">-</span><span style="color: #0000BB">$rel</span><span style="color: #DD0000">&lt;br&gt;\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;close&nbsp;file<br /></span><span style="color: #0000BB">rpm_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$rpmr</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="rpmreader.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.rpmreader.html">RPM Reader 函数</a></div>
 <div class="up"><a href="rpmreader.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
